public class GirlFriend {
    //属性
    private String name;
    private int age;
    private String gender;

    //改进
    //针对每一个私有化的变量都要提供ste和get方法
    public void setName(String n) {
        this.name = n;
    }

    public String getName() {
        return name;
    }

    //年龄
    public void setAge(int age) {
        if (age >= 18 && age <= 50) {
            this.age = age;
        } else {
            System.out.println("非法输入");
        }
    }

    public int getAge() {
        return age;
    }

    //gender
    public void setGender(String g){
        this.gender=g;
    }

    public String getGender(){
        return gender;
    }
    //行为
    public void sleep() {
        System.out.println("女朋友在睡觉");
    }

    public void eat() {
        System.out.println("女朋友在吃饭  ");
    }

}
